#include "memalloc.h"
int main()
{
	int res, id, id1, id2, id3;
	void* addr;
	printf ("Initialization of allocator with size of buffer = 100.\n");
	res = ma_init (100);
	
	printf ("Initialization of allocator again.\n");
	res = ma_init (100);

	printf ("Allocate memory (size = 10). ");
	id1 = ma_alloc (10);
	if (id1 > 0) printf ("Id = %d\n", id1);
	else printf ("\n");

	printf ("Allocate memory (size = 30). ");
	id2 = ma_alloc (30);
	if (id2 > 0) printf ("Id = %d\n", id2);
	else printf ("\n");
	
	printf ("Allocate memory (size = 20). ");
	id3 = ma_alloc (20);
	if (id3 > 0) printf ("Id = %d\n", id3);
	else printf ("\n");
	
	printf ("Allocate memory (size = 60). ");
	id = ma_alloc (60);
	if (id > 0) printf ("Id = %d\n", id);
	else printf ("\n");

	printf ("Get the block of memory with id = %d\n", id2);
	addr = ma_get (id2);
		
	printf ("Free the block of memory with id = %d\n", id2);	
	res = ma_free (id2);
		
	printf ("Release the block of memory with id = %d\n", id2);
	res = ma_release (id2);
	
	printf ("Release again the block of memory with id = %d\n", id2);
	res = ma_release (id2);
	
	printf ("Free the block of memory with id = %d\n", id2);	
	res = ma_free (id2);

	printf ("Allocate memory (size = 15). ");
	id = ma_alloc (15);
	if (id > 0) printf ("Id = %d\n", id);
	else printf ("\n");
	
	printf ("Allocate memory (size = 40). ");
	id = ma_alloc (40);
	if (id > 0) printf ("Id = %d\n", id);
	else printf ("\n");

	printf ("Deinit the allocator.\n");
	ma_deinit();
	
	return 0;
}
